import { get } from "axios";

/**
 * @name 获取天气数据
 * @param {Object} params 传参
 * @param {String} params.key key
 * @param {Number} params.location 城市编码
 * @returns
 */
export const getWeather = ({ key, location }) => {
  return get("https://devapi.qweather.com/v7/weather/now", {
    withCredentials: false,
    headers: {
      "Content-Type": "application/json;charset=utf-8"
    },
    credentials: "omit",
    params: { key, location }
  });
};

/**
 * @name 获取空气数据
 * @param {Object} params 传参
 * @param {String} params.key key
 * @param {Number} params.location 城市编码
 * @returns
 */
export const getAqi = ({ key, location }) => {
  return get("https://devapi.qweather.com/v7/air/now", {
    withCredentials: false,
    headers: {
      "Content-Type": "application/json;charset=utf-8"
    },
    credentials: "omit",
    params: { key, location }
  });
};
